|
|
|
|
|
|
|
When using the Watches window, you can identify which type of Watch expressions are being displayed by the icon on the left edge of each expression, as shown in Figure 18.14. |
|
|
|
|
|
|
|
|
Figure 18.14.
Identifying the Watch expression types using the displayed icons. |
|
|
|
|
|
|
|
|
Using the Immediate Window |
|
|
|
|
|
|
|
|
When you are debugging your application, you may sometimes have a need to execute individual procedures, evaluate expressions, or assign a new value to a variable or property. The Immediate window is the location where you can accomplish any of these tasks. One of the oldest methods of debugging is to print the contents of variables after each calculation. You can: |
|
|
|
|
|
|
|
|
Use MsgBox statements to display these values |
|
|
|
|
|
|
|
|
Use the Debug object to print the values directly to the Immediate window |
|
|
|
|
|
|
|
|
When the application is in Break mode, you can enter Print methods directly in the Immediate window |
|
|
|
|
|
|
|
|
When you are in Break mode, the Immediate window can be used to execute almost any Visual Basic command that you might need. You can print any variable or expression. In addition, if the execution of the application halts within the code that is attached to a form or class, you can also refer to the properties of that form. When doing this, the List Properties/Methods quick list is displayed the same way as when you are entering code during designtime. Besides printing values in the Immediate window, you can also assign values to a variable or property to help isolate the possible cause of an error in the application. |
|
|
|
|
|
|
|
|
Any of these commands are entered as standard Visual Basic code, as shown in Figure 18.15. |
|
|
|
|
|
|
|
|
After you set the values of one or more properties and variables, you can continue the execution of the application to see the results, or you can even execute any procedure that is accessible in your application. After entering a statement as shown in the following code, you would press Enter: |
|
|
|
|
|
|
|
|
SaveSetting App.Title, Settings, MainHeight, Me.Height |
|
|
|
|
|